package com.zz.servlet3.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import java.io.IOException;

@WebFilter(value = {"/*"}, asyncSupported = true,
        initParams = {
                @WebInitParam(name = "a", value = "a"),
                @WebInitParam(name = "b", value = "b")
        }
)
public class LoggerFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        String a = filterConfig.getInitParameter("a");
        String b = filterConfig.getInitParameter("b");
        System.out.println("init a:" + a + ", init b:" + b);
        System.out.println("logger filter init");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("logger filter doFilter");
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {
        System.out.println("logger filter destroy");
    }
}
